/*=============================================================================

  APPLICATION MANAGER MODULE

  FILE: SYSmgr.cpp
  
  DESCRIPTION

    Manager Module Definition

  EXTERNALIZED FUNCTIONS

    
  Copyright (c) DaeSung Engineering Inc. All rights reserved.

=============================================================================*/
/*=============================================================================

                             EDIT HISTORY

  ---------  -------  -------------------------------------------------------
    when       who     what, where, why
  ---------  -------  -------------------------------------------------------
   06/28/03   nso4th   Version 0.1

=============================================================================*/

/*=============================================================================
  HEADER INCLUSION
=============================================================================*/
#include <Cust_AppDef.h>
#include "SYSmgr.h"

/*=============================================================================
  LOCALIZED FUNCTION DEFINITION
=============================================================================*/
extern SYSmgr_cfg_s *smgr_cfg_alloc(void);
extern void smgr_cfg_free(SYSmgr_cfg_s *cfg);

/*=============================================================================
  CONSTANT DEFINITION
=============================================================================*/

/*=============================================================================
  SYSmgr CLASS IMPLEMENTATION
=============================================================================*/
SYSmgr_cfg_s *SYSmgr_CFG_DEFAULT(void)
{
	SYSmgr_cfg_s			*cfg;
	static char			sz_app[128];
	area_cfg_s			*ac;
	
	cfg = smgr_cfg_alloc();

	//Create Base Directory
	FileOp_CreateDirectory(SYSmgr_DEVICE_PATH);
	AppUtil_GetAppName(sz_app, sizeof(sz_app));

//-----------------------------------------------------
// DEVICE.CONFIGURATION
//-----------------------------------------------------
	sprintf(cfg->io_cfg, "%s\\%s.dio", SYSmgr_DEVICE_PATH, sz_app);
	sprintf(cfg->aio_cfg, "%s\\%s.aio", SYSmgr_DEVICE_PATH, sz_app);
	sprintf(cfg->mot_cfg, "%s\\%s.mot", SYSmgr_DEVICE_PATH, sz_app);
	sprintf(cfg->fg_cfg, "%s\\%s.fg", SYSmgr_DEVICE_PATH, sz_app);
	sprintf(cfg->cam_cfg, "%s\\%s.cam", SYSmgr_DEVICE_PATH, sz_app);

//-----------------------------------------------------
// MOTION JOG SPEED
//-----------------------------------------------------
  	cfg->mot_speed_mode = smMOT_SPEED_LOW;

	cfg->mot_speed_tbl[MOT_AXIS_X][smMOT_SPEED_LOW] = 50.0;
	cfg->mot_speed_tbl[MOT_AXIS_Y][smMOT_SPEED_LOW] = 50.0;
	cfg->mot_speed_tbl[MOT_AXIS_A][smMOT_SPEED_LOW] = 50.0;
	cfg->mot_speed_tbl[MOT_AXIS_B][smMOT_SPEED_LOW] = 50.0;
	cfg->mot_speed_tbl[MOT_AXIS_C][smMOT_SPEED_LOW] = 50.0;
	cfg->mot_speed_tbl[MOT_AXIS_D][smMOT_SPEED_LOW] = 50.0;
	cfg->mot_speed_tbl[MOT_AXIS_E][smMOT_SPEED_LOW] = 50.0;

	cfg->mot_speed_tbl[MOT_AXIS_X][smMOT_SPEED_MID] = 100.0;
	cfg->mot_speed_tbl[MOT_AXIS_Y][smMOT_SPEED_MID] = 100.0;
	cfg->mot_speed_tbl[MOT_AXIS_A][smMOT_SPEED_MID] = 100.0;
	cfg->mot_speed_tbl[MOT_AXIS_B][smMOT_SPEED_MID] = 100.0;
	cfg->mot_speed_tbl[MOT_AXIS_C][smMOT_SPEED_MID] = 100.0;
	cfg->mot_speed_tbl[MOT_AXIS_D][smMOT_SPEED_MID] = 100.0;
	cfg->mot_speed_tbl[MOT_AXIS_E][smMOT_SPEED_MID] = 100.0;
	
	cfg->mot_speed_tbl[MOT_AXIS_X][smMOT_SPEED_HIGH] = 150.0;
	cfg->mot_speed_tbl[MOT_AXIS_Y][smMOT_SPEED_HIGH] = 150.0;
	cfg->mot_speed_tbl[MOT_AXIS_A][smMOT_SPEED_HIGH] = 150.0;
	cfg->mot_speed_tbl[MOT_AXIS_B][smMOT_SPEED_HIGH] = 150.0;
	cfg->mot_speed_tbl[MOT_AXIS_C][smMOT_SPEED_HIGH] = 150.0;
	cfg->mot_speed_tbl[MOT_AXIS_D][smMOT_SPEED_HIGH] = 150.0;
	cfg->mot_speed_tbl[MOT_AXIS_E][smMOT_SPEED_HIGH] = 150.0;

	//-----------------------------------------------------
	// MOTION POSITION TABLE
	//-----------------------------------------------------
	// LOADING POSITIOIN
	cfg->mot_pos_tbl[HMOT_X_LOAD_POS] = (0.0);
	cfg->mot_pos_tbl[HMOT_Y_LOAD_POS] = (0.0);
	cfg->mot_pos_tbl[HMOT_Y_SCAN_POS] = (0.0);

	cfg->mot_pos_tbl[HMOT_X_NLIMIT_POS] = MOT_POS_MIN_X;
	cfg->mot_pos_tbl[HMOT_X_PLIMIT_POS] = MOT_POS_MAX_X;
	
	cfg->mot_pos_tbl[HMOT_Y_NLIMIT_POS] = MOT_POS_MIN_Y;
	cfg->mot_pos_tbl[HMOT_Y_PLIMIT_POS] = MOT_POS_MAX_Y;

	cfg->mot_pos_tbl[HMOT_A_NLIMIT_POS] = MOT_POS_MIN_A;
	cfg->mot_pos_tbl[HMOT_A_PLIMIT_POS] = MOT_POS_MAX_A;
	
	cfg->mot_pos_tbl[HMOT_B_NLIMIT_POS] = MOT_POS_MIN_B;
	cfg->mot_pos_tbl[HMOT_B_PLIMIT_POS] = MOT_POS_MAX_B;

	cfg->mot_pos_tbl[HMOT_C_NLIMIT_POS] = MOT_POS_MIN_C;
	cfg->mot_pos_tbl[HMOT_C_PLIMIT_POS] = MOT_POS_MAX_C;
	
	cfg->mot_pos_tbl[HMOT_D_NLIMIT_POS] = MOT_POS_MIN_D;
	cfg->mot_pos_tbl[HMOT_D_PLIMIT_POS] = MOT_POS_MAX_D;

	cfg->mot_pos_tbl[HMOT_E_NLIMIT_POS] = MOT_POS_MIN_E;
	cfg->mot_pos_tbl[HMOT_E_PLIMIT_POS] = MOT_POS_MAX_E;

	//-----------------------------------------------------
	// MOTION VELOCITY TABLE
	//-----------------------------------------------------
	// LOADING
	cfg->mot_vel_tbl[HMOT_X_LOAD_VEL] = 150.0;
	cfg->mot_vel_tbl[HMOT_Y_LOAD_VEL] = 150.0;
	cfg->mot_vel_tbl[HMOT_Y_SCAN_VEL] = 0.0;

	//-----------------------------------------------------
	// APPLICATION
	//-----------------------------------------------------
	ac = &cfg->area_cfg;

	ac->meaCNT = 0.0;
	ac->Tstart = 0.0;
	ac->Tinterval = 0.0;

	ac->mea_time = 0;
	sprintf(ac->img_path, "D:\\IMAGE");

	return	cfg;
}
